




clear all 
use the_dataset.dta

keep if  dataset_inverse == 1

keep culture1 culture2 culture_d  unemp culture1 case_1 case_2 CCAA1  unemp_t1 unemp_t2 ///
educ_basic1-educ_sup1 age051-age661 income1 income2 income_d NMIEMB1 size_dummy1-size_dummy5 number_spanish1 ccaadummy1-ccaadummy17 ANOENC1 ANOENC2 yeardummy1-yeardummy9

global covariates3 culture1 educ_basic1-educ_sup1 age051-age661 income1 NMIEMB1 size_dummy1-size_dummy5 number_spanish1 ccaadummy1-ccaadummy17 yeardummy1-yeardummy9


* Participation
gen c_c1 = 1 if culture1 > 0
gen c_c2 = 1 if culture2 > 0
replace c_c2 = 0 if culture2 == 0

* Gen inverse treatment
gen case_3 = 1 if unemp_t1==1 & unemp_t2<2 & unemp_t2>=0
gen case_4 = 1 if unemp_t1==2 & unemp_t2<3 & unemp_t2>=1

gen     treated = 1 if unemp==-1
replace treated = 0 if unemp==0

* Inverse T10
preserve
keep if case_3==1 
* Unconditonal
*bys treated: sum culture_d
absdid culture_d , tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
* participacion
absdid c_c2, tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
keep if c_c2==1 
* COP
*bys treated: sum culture_d
absdid culture_d , tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore

* Inverse T21
preserve
keep if case_4==1 
* drop an outlier
drop if income_d < -7400 & treated == 0
* Unconditonal
absdid culture_d , tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
* participacion
absdid c_c2, tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
keep if c_c2==1 
* COP
*bys treated: sum culture_d
absdid culture_d , tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
absdid income_d  , tvar(treated) xvar($covariates3) sle
sum treated if e(sample)==1
dis "treated=" r(N)*r(mean)
dis "untreated=" r(N)*(1-r(mean))
restore
























